//
//  HttpUserPtl.m
//  Cat
//
//  Created by lushitong on 2018/12/1.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "HttpUserPtl.h"
#import "FLRequest.h"
#import "FLTool.h"
#import "FMDBUser.h"

#define API_senCode @"verify/code"
#define API_login @"login"
#define API_User @"user/rank/get"
#define API_Member @"user/get"
#define API_feedBakc @"advice/put"

@implementation HttpUserPtl

+ (void)sendVerifyCodeWithMobile:(NSString *)phoneString
					 withSuccuss:(FLSuccess)success
						 failure:(FLFailure)failure {
	NSDictionary *params = @{@"mobile": phoneString ? phoneString :@(0)};
	[FLRequest GET:[FLTool getFullPath:API_senCode] parameters:params success:success failure:failure];
}

+ (void)loginWithPhoneNumber:(NSString *)phoneString
			   andVerifyCode:(NSString *)code
				  inviteCode:(NSString *)inviteCode
				 withSuccuss:(FLSuccess)success
					 failure:(FLFailure)failure {
	NSDictionary *params = @{@"mobile": phoneString ? phoneString :@(0),
							 @"verifyCode":code ? code :@(0),
							 @"inviteCode":inviteCode ? inviteCode :@(0)
							 };
	[FLRequest POST:[FLTool getFullPath:API_login] parameters:params success:success failure:failure];
}

+ (void)getUserIfnowithSuccuss:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest GET:[FLTool getFullPath:API_User] parameters:@{} success:success failure:failure];
}

+ (void)getMemberInfoSucces:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest GET:[FLTool getFullPath:API_Member] parameters:@{} success:success failure:failure];
}

+ (void)senFeedBackWithContext:(NSString *)feedBack
				   withSuccuss:(FLSuccess)success
					   failure:(FLFailure)failure {
	NSDictionary *params = @{@"content": feedBack ? feedBack :@""};
	[FLRequest POST:[FLTool getFullPath:API_feedBakc] parameters:params success:success failure:failure];
	
}

+ (void)getEarnInfowithSuccuss:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest GET:[FLTool getFullPath:@"user/earn/get"] parameters:@{} success:success failure:failure];
}

+ (void)getFansCountInfo:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest GET:[FLTool getFullPath:@"relation/count/get"] parameters:@{} success:success failure:failure];
}

+ (void)getElationListWihIndex:(NSNumber *)index andType:(NSString *)type withSuccuss:(FLSuccess)success failure:(FLFailure)failure {
	NSDictionary *params = [[NSDictionary alloc] init];
	
	if (type.length > 0) {
		params= @{@"index":index ? index : @(0),
								 @"size":@(20),
								 @"type":type ? type : @(0)
								 };
	} else {
		params= @{@"index":index ? index : @(0),
				  @"size":@(20)
				  };
	}
	
	[FLRequest GET:[FLTool getFullPath:@"relation/list"] parameters:params success:success failure:failure];
}

+ (void)userUpdateInfo:(NSString *)avatar
		  withNickName:(NSString *)nickString
		   withSuccuss:(FLSuccess)success
			   failure:(FLFailure)failure {
	NSDictionary *params= @{@"avatar":avatar ? avatar : @"",
							@"nickName": nickString ? nickString : @""};
	
	[FLRequest POST:[FLTool getFullPath:@"user/update"] parameters:params success:success failure:failure];
}

+ (void)upLoadFile:(UIImage *)avatarImage withSuccuss:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest uploadFileWithURL:[FLTool getFullPath:@"file/upload"] andImage:avatarImage progress:nil success:success failure:failure];
}

+ (void)fundoutPutnSuccessInfowithSuccuss:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest POST:[FLTool getFullPath:@"balance/fundout/put"] parameters:@{} success:success failure:failure];
}

+ (void)balanceListIndex:(NSNumber *)index success:(FLSuccess)success failure:(FLFailure)failure {
	NSDictionary *params = @{@"index":index?index:@(0),
							 @"size":@(20)
							 };
	
	[FLRequest GET:[FLTool getFullPath:@"balance/list"] parameters:params success:success failure:failure];
}


+ (void)brokListIndex:(NSNumber *)index type:(NSString *)type success:(FLSuccess)success failure:(FLFailure)failure {
	NSDictionary *params = @{@"index":index?index:@(0),
							 @"size":@(20),
							 @"status":type ? type :@""
							 };
	[FLRequest GET:[FLTool getFullPath:@"prize/list"] parameters:params success:success failure:failure];
}

+ (void)balanceGetSuccess:(FLSuccess)success failure:(FLFailure)failure {
	[FLRequest GET:[FLTool getFullPath:@"balance/get"] parameters:@{} success:success failure:failure];
}

+ (void)balanceUpdatePayName:(NSString *)payName realName:(NSString *)realName phoneNumber:(NSString *)phoneNumber verCode:(NSString *)code withSuccuss:(FLSuccess)success failure:(FLFailure)failure {
	NSDictionary *dic = @{@"alipayNo":payName?payName:@"",
						  @"realName":realName?realName:@"",
						  @"veriftCode":code?code:@"",
						  @"phone":phoneNumber ? phoneNumber :@"",
						  };
	
	[FLRequest POST:[FLTool getFullPath:@"balance/update"] parameters:dic success:success failure:failure];
}

+ (void)balanceAmount:(NSNumber *)amount putSuccess:(FLSuccess)success failure:(FLFailure)failure {
    NSDictionary *dic = @{@"amount":amount ? amount : @(0)};
	[FLRequest POST:[FLTool getFullPath:@"balance/fundout/put"] parameters:@{} success:success failure:failure];
}

+ (void)getInviteStausByPhone:(NSString *)phone success:(FLSuccess)success failure:(FLFailure)failure {
    NSDictionary *dic = @{@"mobile":phone};
    [FLRequest GET:[FLTool getFullPath:@"invite/status/get"] parameters:dic success:success failure:failure];
}

+ (void)getInviteListWithIndex:(NSNumber *)index success:(FLSuccess)success failure:(FLFailure)failure {

    NSMutableDictionary *dic = @{@"size":@"20",
                                 @"index":index ? index :@(1)
                                 }.mutableCopy;
    [FLRequest GET:[FLTool getFullPath:@"user/invite/list"] parameters:dic success:success failure:failure];
}

@end
